﻿package main

import "fmt"

func fib(first int, second int, n int) int {
    if n <= 2 {
        return 1
    } else if n == 3 {
        return first + second
    }
    return fib(second, first + second, n - 1)
}

func fib2(n int) int {
    first := 1
    second := 1
    var tmp int
    for i := n; i >= 3; i-- {
        tmp = first
        first = second
        second = tmp + second
    }
    return second
}

func fib3(n int) int {
    first := 1
    second := 1
    var ret int
    for i := 3; i <= n; i++ {
        ret = first + second
        first = second
        second = ret
    }
    if n < 3 {
        return 1
    }
    return ret
}

func main() {
    fmt.Print("请输入一个小一点的正整数：")
    var n int
    fmt.Scanf("%d\n", &n)
    fmt.Println(fib(1, 1, n))
    //fmt.Println(fib2(n))
    //fmt.Println(fib3(n))
}